home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / +system+ / afcdfind-handlematch.dopus5 < prev    next >
Text File  |  1999-06-28  |  4KB  |  131 lines

  1. /* $VER: AFCDFind-HandleMatch.dopus5 1.3 (23.6.99)
  2. **
  3. ** Support script used by AFCDFind
  4. **
  5. ** Usage: OpenLister.dopus5 pathname
  6. ** Looks in ENV:AFCDFind_DOpus for config options
  7. **
  8. ** Author: Oliver Roberts
  9. ** E-Mail: oliver.roberts@iname.com
  10. **    WWW: http://www.nanunanu.org/~oliver/
  11. */
  12.  
  13. options results
  14. options failat 21
  15.  
  16. /* DOpus running? */
  17.  
  18. If ~Show("P","DOPUS.1") Then Do
  19.    EXIT
  20. End
  21.  
  22. Address "DOPUS.1"
  23.  
  24. /* Check for required lib */
  25. if ~show('l', 'rexxsupport.library') then do
  26.    call addlib('rexxsupport.library', 0, -30, 0)
  27.    if ~show('l', 'rexxsupport.library') then do
  28.       dopus request '"This feature requires LIBS:rexxsupport.library" OK'
  29.       EXIT
  30.    end
  31. end
  32.  
  33. /* Check version and exit if older than v5.5 */
  34.  
  35. dopus version
  36. If ( result='RESULT' | translate(result,'.',' ') < 5.1218 ) then do
  37.    dopus request '"This feature requires DOpus v5.5 or greater." OK'
  38.    EXIT
  39. end
  40.  
  41. /* Parse in arguments and options in environment variable */
  42.  
  43. parse arg pathname
  44.  
  45. CALL GetEnv('AFCDFind_DOpus')
  46. config = RESULT
  47.  
  48. parse var config . listermode
  49.  
  50. /* Turn AmigaDOS 'Insert Volume' requesters off */
  51.  
  52. pragma('W','N')
  53.  
  54. /* Determine if the correct CD is inserted, and if not, ask the user to
  55.    insert it */
  56.  
  57. volume = left(pathname,pos(':',pathname))
  58. DO UNTIL (correctcd = 0 | exists(volume))
  59.   correctcd = 1;
  60.   If ~Exists(volume) Then Do
  61.       msg = "Please insert Amiga Format CD " || substr(volume,5,length(volume)-5)
  62.       dopus request '"'msg'" OK|Cancel'
  63.       correctcd = RC
  64.   end
  65. end
  66.  
  67. /* Do the action if requested CD is available */
  68.  
  69. if (correctcd = 1 & exists(volume)) then do
  70.    stat = statef(pathname)
  71.    if (WORD(stat,1) = 'DIR') then do
  72.       /* Drawer button: Open the lister */
  73.       /* If drawer has no icon, make sure we are in showall mode */
  74.       drawericon = pathname
  75.       if (right(drawericon,1) = '/') then drawericon = left(drawericon,length(drawericon)-1)
  76.       drawericon = drawericon || '.info'
  77.       hasicon = 1
  78.       if (~exists(drawericon)) then do
  79.          if (find(listermode,'showall') == 0) then listermode = listermode 'showall'
  80.          hasicon = 0
  81.       end
  82.  
  83.       dopus version
  84.       if (translate(result,'.',' ') < 5.8) then do
  85.          /* Open the lister the messy way - workaround for bug in DOpus */
  86.          lister new pathname
  87.          ourlister = RESULT
  88.          if (word(listermode,1) ~= 'name') then do
  89.             lister set ourlister mode listermode
  90.          end
  91.       end
  92.       else do
  93.          /* Open the list the clean way with DOpus 5.8 or higher */
  94.          if (hasicon == 1 & word(listermode,1) ~= 'name') then do
  95.             lister new mode listermode fromicon pathname
  96.          end
  97.          else do
  98.             lister new mode listermode pathname
  99.          end
  100.       end
  101.    end
  102.    else do
  103.       /* File button: get DOpus to act on file according to filetypes */
  104.       command doubleclick pathname
  105.    end
  106. end
  107.  
  108. /* Finished */
  109.  
  110. EXIT
  111.  
  112. /* Procedure definitions */
  113.  
  114. /* GetEnv()  return the value of an environmental variable           */
  115. GetEnv: procedure
  116.    /* Arguments:                                                     **
  117.    **   arg(1) := The name of the variable to retrieve               **
  118.    ** Returns     a string                                           */
  119.    /* Use function from rexxarplib if it's available                 */
  120. if show('L', 'rexxarplib.library') then
  121.    return 'GetEnv'(arg(1))
  122.  
  123.    /*  OPEN()  will fail if variable is not defined. Null will be    **
  124.    ** returned in that case                                          */
  125. if open(6Env, 'env:'arg(1), 'R') then do
  126.    EnvVar = readln(6Env)
  127.    call close 6Env
  128. end
  129. else EnvVar = ''
  130. return EnvVar
  131.